<?php

use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
use Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees;
use Fisharebest\Webtrees\Http\RequestHandlers\RenumberTreeAction;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Tree;

/**
 * @var Tree          $tree
 * @var string        $title
 * @var array<string> $xrefs
 */

?>

<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees '), $title]]) ?>

<h1><?= $title ?></h1>

<p>
    <?= I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.') ?>
</p>

<p>
    <?= I18N::translate('You can renumber the records in a family tree, so that these internal reference numbers are not duplicated in any other family tree.') ?>
</p>

<p>
    <?= I18N::plural('This family tree has %s record which uses the same “XREF” as another family tree.', 'This family tree has %s records which use the same “XREF” as another family tree.', count($xrefs), I18N::number(count($xrefs))) ?>
</p>

<?php if (!empty($xrefs)) : ?>
    <p>
        <?= I18N::translate('You can renumber this family tree.') ?>
    </p>

    <form method="post" action="<?= e(route(RenumberTreeAction::class, ['tree' => $tree->name()])) ?>">
        <?= csrf_field() ?>
        <button type="submit" class="btn btn-primary">
            <?= view('icons/save') ?>
            <?= /* I18N: A button label. */
            I18N::translate('continue') ?>
        </button>

        <?= I18N::translate('Caution! This may take a long time. Be patient.') ?>
    </form>
<?php endif ?>
